package com.hanrui.android.fragment.message.audit.businesstravel;

import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.hanrui.android.R;
import com.hanrui.android.library.base.BaseFragment;
import com.hanrui.android.model.BusinessTravelDetailBean;
import com.hanrui.android.net.contract.message.audit.businesstravel.BusinessTravelDetailContract;
import com.hanrui.android.net.presenter.message.audit.businesstravel.BusinessTravelDetailPresenter;

import butterknife.BindView;

/**
 * 出差审批基本信息
 *
 */

public class BusinessTravelDetailFragment extends BaseFragment<BusinessTravelDetailPresenter> implements BusinessTravelDetailContract.View {
    @BindView(R.id.main_title)
    TextView mainTitle;
    @BindView(R.id.subhead_title)
    TextView subheadTitle;
    @BindView(R.id.travel_title)
    TextView travelTitle;
    @BindView(R.id.travel_company)
    TextView travelCompany;
    @BindView(R.id.travel_department)
    TextView travelDepartment;
    @BindView(R.id.travel_time)
    TextView travelTime;
    @BindView(R.id.travel_level)
    TextView travelLevel;
    @BindView(R.id.travel_user)
    TextView travelUser;
    @BindView(R.id.travel_people)
    TextView travelPeople;
    @BindView(R.id.travel_gotime)
    TextView travelGotime;
    @BindView(R.id.travel_backtime)
    TextView travelBacktime;
    @BindView(R.id.travel_ticket)
    TextView travelTicket;
    @BindView(R.id.travel_room)
    TextView travelRoom;
    @BindView(R.id.travel_termini)
    TextView travel_termini;
    @BindView(R.id.travel_type)
    TextView travelType;
    @BindView(R.id.travel_car)
    TextView travelCar;
    @BindView(R.id.travel_reson)
    TextView travelReson;
    @BindView(R.id.travel_remark)
    TextView travelRemark;
    @BindView(R.id.car_ll)
    LinearLayout carLl;
    @BindView(R.id.name)
    TextView name;
    @BindView(R.id.thing_title)
    TextView thingTitle;
    @BindView(R.id.wind_meet)
    TextView windMeet;
    @BindView(R.id.leaders)
    TextView leaders;
    @BindView(R.id.head_company)
    TextView headCompany;
    @BindView(R.id.duty_company)
    TextView dutyCompany;
    @BindView(R.id.duty_people)
    TextView dutyPeople;
    @BindView(R.id.from)
    TextView from;
    @BindView(R.id.vote_meet)
    TextView voteMeet;
    @BindView(R.id.money_meet)
    TextView moneyMeet;

    String taskId,procInsId,bizId;

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_businesstraveldetail;
    }

    @Override
    protected void initInjector() { mFragmentComponent.inject(this); }

    @Override
    protected void initView(View view) {

        taskId = getArguments().getString("taskId");
        procInsId = getArguments().getString("procInsId");
        bizId = getArguments().getString("bizId");

        mPresenter.businessTravelBizDetail(getActivity(),taskId,procInsId,bizId);

    }



    public static BusinessTravelDetailFragment newInstance(String taskId, String procInsId, String bizId) {
        BusinessTravelDetailFragment fragment = new BusinessTravelDetailFragment();
        Bundle bundle = new Bundle();
        bundle.putString("taskId", taskId);
        bundle.putString("procInsId", procInsId);
        bundle.putString("bizId", bizId);
        fragment.setArguments(bundle);
        return fragment;
    }

    @Override
    public void businessTravelBizDetail(BusinessTravelDetailBean data) {

        if (null != data) {

            mainTitle.setText(data.getDetail().getUserName()+"的出差审批");
            subheadTitle.setText(data.getDetail().getApplyDate());
            travelTitle.setText(data.getDetail().getTitle());
            travelCompany.setText(data.getDetail().getCompanyName());
            travelDepartment.setText(data.getDetail().getOfficeName());
            travelTime.setText(data.getDetail().getApplyDate());
            travelLevel.setText(data.getDetail().getUrgency());
            travelUser.setText(data.getDetail().getUserName());
            travelGotime.setText(data.getDetail().getBeginDate());
            travelBacktime.setText(data.getDetail().getEndDate());
            travelTicket.setText(data.getDetail().getBookTicket());
            travelRoom.setText(data.getDetail().getBookHotel());
            travel_termini.setText(data.getDetail().getDestination());
            travelType.setText(data.getDetail().getTranType());
            travelCar.setText(data.getDetail().getIfCar());
            travelReson.setText(data.getDetail().getReason());
            travelRemark.setText(data.getDetail().getRemark());

            if (data.getDetail().getIfCar().equals("是")) {

                name.setText(data.getDetail().getCarUser());
                thingTitle.setText(data.getDetail().getUserPhone());
                windMeet.setText(data.getDetail().getApplicantName());
                leaders.setText(data.getDetail().getPersonNum());
                headCompany.setText(data.getDetail().getCompanyName());
                dutyCompany.setText(data.getDetail().getOfficeName());
                dutyPeople.setText(data.getDetail().getCarReason());
                from.setText(data.getDetail().getVehicleRoute());
                voteMeet.setText(data.getDetail().getStartTime());
                moneyMeet.setText(data.getDetail().getEndTime());
                return;

            		}

                carLl.setVisibility(View.GONE);
        }

    }
}
